﻿<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

//设置参数
    //邮件配置
    $config = array(
        'SMTP_HOST'   => 'smtp.163.com', //SMTP服务器
        'SMTP_PORT'   => '465', //SMTP服务器端口
        'SMTP_USER'   => '18915077727', //SMTP服务器用户名
        'SMTP_PASS'   => '8766239p', //SMTP服务器密码
        'FROM_EMAIL'  => '18915077727@163.com', //发件人EMAIL
        'FROM_NAME'   => '网站管理员', //发件人名称
        'REPLY_EMAIL' => 'qj@wxjysh.com', //回复EMAIL（留空则为发件人EMAIL）
        'REPLY_NAME'  => '网站管理员',//回复名称（留空则为发件人名称）
        'TO_EMAIL'    => 'qj@wxjysh.com',//需要发送的邮件地址
        'Subject'     =>'您有新的留言',//发送的主题
        'CONTENT'     =>'邮件正文'

    );
	
	
	
	if($_POST['name']){
		$str="姓名：".$_POST['name']."<br>";
		$str.="电话：".$_POST['phone']."<br>";
		$str.="日期：".$_POST['time']."<br>";
		$str.="地址：".$_POST['address']."<br>";
		$config['CONTENT']=$str;
		
		
		$config['TO_EMAIL']='3553710292@qq.com';
	
		
		
	}




$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = $config['SMTP_HOST'];  // specify main and backup server
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username =  $config['SMTP_USER'];  // SMTP服务器用户名
$mail->Password =  $config['SMTP_PASS'];  // SMTP服务器密码

$mail->From = $config['FROM_EMAIL'];
$mail->FromName = $config['FROM_NAME'];
// $mail->AddAddress("3553710292@qq.com", "Admin");
$mail->AddAddress($config['TO_EMAIL']);                  // name is optional
$mail->AddReplyTo($config['REPLY_EMAIL'], "REPLY_NAME");

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
// $mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
// $mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = $config['Subject'];
$mail->Body    = $config['CONTENT'];
// $mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

//header('Location:http://wxjysh.com/');
//echo "发送成功";
$url="http://wxjysh.com/";
//echo '<script language="javascript">setTimeout("window.location.href=",3000)</script>';

echo '<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>发送邮件</title>
    <meta http-equiv="refresh" content="3;URL=http://baidu.com" /> 
</head>
<body>
    <div>
        <br />
       
         
        发送成功     <br />
        本页面将在<span style="color:#FF0000; font-weight:bold;">3</span>秒后跳转
    </div>
</html>';

?>